package net.httpconn;

import java.io.IOException;
import java.net.MalformedURLException;

public class HttpCommandFactory {
	
	public static HttpCommand getCommand (String method, String url, String content, String c_type, int timeout ) throws MalformedURLException, IOException {
		HttpCommand com=null;
		
		if (method.equalsIgnoreCase("GET"))
			com = new GetCommand();
		else if (method.equalsIgnoreCase("POST")) {
			com = new PostCommand();
			com.setContent(content);
		}
		else if (method.equalsIgnoreCase("DELETE")) {
			com = new DeleteCommand();
			com.setContent(content);
		}
		else if (method.equalsIgnoreCase("PUT")) {
			com = new PutCommand();
			com.setContent(content);
		}
		if (c_type != null)  com.setC_type(c_type);
		
		com.setUrl(url);
		com.setMethod(method);
		com.setTimeout ( timeout );
		com.initializeConnection();
		return com;
	}
}
